#include "genericwid.h"

genericWid::genericWid(QString pixPath)
{
        pix = new QPixmap(QString(QApplication::applicationDirPath() + pixPath));
        this->setPixmap(*pix);

        qDebug() << "genericWid =>" << QString(QApplication::applicationDirPath() + pixPath);
}

void genericWid::mousePressEvent ( QGraphicsSceneMouseEvent * event )
{
    emit this->clicked();
    //qDebug() << "clicked";

    if(event->pos().x() < this->boundingRect().width() / 2){
        emit this->clickedX1Half();
        //qDebug() << "clickedX1Half()";

        if(event->pos().y() < this->boundingRect().height() / 2){
            emit this->clickedY1Half();
            //qDebug() << "clickedY1Half()";
            emit this->clicked1Quarter();
        }else{
            emit this->clickedY2Half();
            //qDebug() << "clickedY2Half()";
            emit this->clicked3Quarter();
        }
    }else{
        emit this->clickedX2Half();
        //qDebug() << "clickedX2Half()";

        if(event->pos().y() < this->boundingRect().height() / 2){
            emit this->clickedY1Half();
            //qDebug() << "clickedY1Half()";
            emit this->clicked2Quarter();
        }else{
            emit this->clickedY2Half();
            //qDebug() << "clickedY2Half()";
            emit this->clicked4Quarter();
        }
    }
}

